package ArrayList;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: MENG
 * Date: 2022-06-28
 * Time: 20:58
 */
public class ArrayListDemo {
    public static void main(String[] args) {
     /*   LinkedList<Integer> list1 = new LinkedList<>();
        ArrayList<Number> arrayList = new ArrayList<>(list1);

        ArrayList<Character> arrayList1 = new ArrayList<>(22);

        List<Integer> list = new ArrayList<>();
        list.add(1);
        List<Character> list2 = new LinkedList<>();*/

        List<Integer> list = new ArrayList<>();
        list.add(25);
        list.add(28);
        System.out.println(list);
        list.add(0,1);
        List<Integer> list2 = new ArrayList<>();
        list2.add(99);
        list.addAll(list2);
        list.remove(0);
        System.out.println(list.get(0));
        list.set(0,98);
        System.out.println(list.indexOf(98));
        System.out.println(list.subList(0,2));
        list.set(0,2);
        System.out.println(list);
        List<Integer> list1 = new ArrayList<>(list);
        System.out.println(list1);

        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        for (Integer integer:list) {
            System.out.println(integer);
        }

        //Iterator迭代器
        Iterator it =list.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }
        //ListIterator迭代器
        ListIterator it1 = list.listIterator();
        while(it1.hasNext()){
            System.out.println(it1.next());
        }

    }
}